//
//  ProblemViewController.m
//  AntsExpress
//
//  Created by slccper on 16/1/12.
//  Copyright © 2016年 slccper. All rights reserved.
//

#import "ProblemViewController.h"
#import "ProblemNextController.h"
#import "ProblemController.h"
@interface ProblemViewController ()<UITableViewDataSource,UITableViewDelegate>
{
    NSMutableArray *_tableList;
}
@property (weak, nonatomic) IBOutlet UITableView *tableView;

@end

@implementation ProblemViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title=@"常見問題";
    self.tableView.rowHeight=50;
    self.tableView.tableFooterView=[[UIView alloc]init];
    // Do any additional setup after loading the view from its nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
-(void)getWebData
{
    if ([clsOtherFun CheckNetworkStatus:YES]) {
        [clsOtherFun showLoadingView:@"正在獲取數據..."];
        if (ants) {
            ants.delegate=nil;
            ants=nil;
        }
        ants = [[clsAntsService alloc]init];
        ants.delegate=self;
        [ants GetQuestionType];
    }
}
#pragma mark - UITableView
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return _tableList.count;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"TaobaoCell";
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        //        cell.parentViewController=self;
    }
    NSDictionary *dic = [_tableList objectAtIndex:indexPath.section];
    NSString *name = [dic objectForKey:@"name"];
    if ([name isKindOfClass:[NSNull class]]) {
        name=@"";
    }
    [cell.textLabel setText:name];
    return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSDictionary *dic = [_tableList objectAtIndex:indexPath.section];
    NSString *type = [dic objectForKey:@"type"];
    if ([type isEqualToString:@"1"]) {
        ProblemController *next = [[ProblemController alloc]initWithNibName:@"ProblemController" bundle:nil];
        next.dic=dic;
        next.isBack=YES;
        [self.navigationController pushViewController:next animated:YES];
        
    }else{
        ProblemNextController *next = [[ProblemNextController alloc]initWithNibName:@"ProblemNextController" bundle:nil];
        next.dic=dic;
        next.isBack=YES;
        [self.navigationController pushViewController:next animated:YES];
    }
}
-(void)getAntsDataSuccess:(NSInteger)type :(NSMutableDictionary *)pDictionary
{
    [clsOtherFun hideLoadingView];
    NSDictionary *dic = [pDictionary objectForKey:@"data"];
    NSString *status = [dic objectForKey:@"status"];
    if ([status integerValue]==200) {
        _tableList = [dic objectForKey:@"data"];
        [self.tableView reloadData];
    }else{
        [clsOtherFun ShowMsgWithNoData];
    }
    
}
@end
